<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "captcha_log".
 *
 * @property integer $id
 * @property string $mobile
 * @property integer $action
 * @property string $code
 * @property integer $create_time
 */
class CaptchaLog extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'captcha_log';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['action', 'create_time'], 'integer'],
            [['mobile', 'code'], 'string', 'max' => 16],
            [['mobile', 'code'], 'required'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'mobile' => '手机号',
            'action' => '操作类型',
            'code' => '图片验证码',
            'create_time' => '创建时间',
        ];
    }

    public function save($runValidation = true, $attributeNames = null)
    {
        if($this->isNewRecord) {
            $this->create_time=time();
        }
        return parent::save($runValidation, $attributeNames);
    }
}
